package cn.how2go.api.service.impl;

import cn.how2go.api.common.WarningCount;
import cn.how2go.api.entity.UserWarnning;
import cn.how2go.api.entity.Warning;
import cn.how2go.api.mapper.WarningMapper;
import cn.how2go.api.service.WarningService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LGP
 * @since 2020-05-31
 */
@Service
public class WarningServiceImpl extends ServiceImpl<WarningMapper, Warning> implements WarningService {

    @Autowired
    private WarningMapper warningMapper;

    @Override
    public List<WarningCount> countByType() {
        return warningMapper.countByType();
    }

    public List<UserWarnning> getListUserWarnning(boolean isOld){
        //EntityWrapper<UserWarnning> entityWrapper = new EntityWrapper<>();
        List<UserWarnning>  result = null;
        if(isOld){
            //entityWrapper.eq("state",1).or().eq("state",2);
            result = warningMapper.getListUserWarinning();
        }else{
            //entityWrapper.eq("state", 0);
            result = warningMapper.getNewListUserWarinning();
        }
        return result;
    }
}
